# 抖码算法，让算法学习变得简单有趣
# 作者：老汤


# 反转 head 链表，然后返回反转后的新的头节点
def reverse_list(head):
    if head is None or head.next is None:
        return head

    ret = reverse_list(head.next)

    # 反转两个节点
    head.next.next = head
    head.next = None

    return ret